package com.mall.controller;



import com.mall.entity.CategoryVO;
import com.mall.entity.IndexImg;
import com.mall.entity.ProductVO;
import com.mall.service.CategoryService;
import com.mall.service.IndexImgService;
import com.mall.service.ProductService;
import com.mall.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/index")
@Api(value = "提供首页数据显示所需要的接口",tags = "首页管理")
public class IndexController {
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private IndexImgService indexImgService;

    @Autowired
    private ProductService productService;

    /**
     *左侧三级菜单
     * @param categoryLevel
     * @return
     */
    @GetMapping("/getCategories")
    @ApiOperation("左侧三级查询")
    public ResultVO getCategories(Integer categoryLevel){
        List<CategoryVO> list =categoryService.getCategories(categoryLevel);
        return ResultVO.success(list);
    }

    /**
     * 轮播图
     * @return
     */
    @GetMapping("/getIndexImgs")
    @ApiOperation("轮播图接口")
    public ResultVO listIndexImgs(){
        List<IndexImg> list = indexImgService.listIndexImgs();
        return ResultVO.success(list);
    }

    /**
     *
     * @return
     */
    @GetMapping("/list-recommends")
    @ApiOperation("查询推荐商品接⼝")
    public ResultVO listRecommendProducts(){
        return productService.listRecommendProducts();
    }
    @GetMapping("/category-recommends")
    @ApiOperation("分类商品推荐接口")
    public ResultVO listFeaturedCategories(){
        return categoryService.listFeaturedCategories();
    }
}
